byte LEDVCC = 8;
//PWM pins
byte RED = 9;
byte BLUE = 10;
byte GREEN = 11;
byte COLORS[] = {RED, BLUE, GREEN};

void setup ()
{
  pinMode(LEDVCC, OUTPUT);
pinMode(RED, OUTPUT);
pinMode(BLUE, OUTPUT);
pinMode(GREEN, OUTPUT);
}

//  MAIN CODE
void loop ()
{
  digitalWrite(LEDVCC, HIGH);
//direction: up = true, down = false
boolean dir = true;
int i = 0;

while(1)
{
fade(COLORS[i%3], dir);
i++;
dir = !dir;
}
}

void fade(byte Led, boolean dir)
{
int i;

//if fading up
if (dir)
{
for (i = 0; i < 254; i++) {
   analogWrite(Led, i);
   delay(1);
}
}
}

